package com.service.serviceImpl.base;

import com.dao.base.BaseDao;
import com.entity.BaseEntity;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created by Administrator on 2018-10-11 0011.
 */
public abstract class BaseServiceImpl<Dao extends BaseDao<T>, T extends BaseEntity> implements BaseService<T> {


    @Autowired
    private Dao dao;

    @Override
    public T getById(Integer id) throws Exception {
        return dao.selectByPrimaryKey(id);
    }

    @Override
    public boolean insert(T t) throws Exception {
        return dao.insertSelective(t) == 1 ? true : false;
    }

    @Override
    public boolean deleteById(Integer id) throws Exception {
        return dao.deleteByPrimaryKey(id) == 1 ? true : false;// 物理删除
    }

    @Override
    public boolean update(T t) throws Exception {
        return dao.updateByPrimaryKeySelective(t) == 1 ? true : false;
    }

    @Override
    public List<T> getList(T t) throws Exception {
        return dao.queryList(t);
    }
}
